package com.mvvm.ktnet.ui.testChart

import android.os.Bundle
import android.util.Log
import com.alibaba.fastjson.JSON
import com.mvvm.ktnet.R
import com.mvvm.ktnet.base.myappbase.BaseDbActivity
import com.mvvm.ktnet.base.viewmodel.BaseViewModel
import com.mvvm.ktnet.databinding.AcTestChartBinding
import com.mvvm.ktnet.utils.ListCopy
import nethttp.RxHttp
import nethttp.toResponse
import rxhttp.toOkResponse
import rxhttp.wrapper.utils.LogUtil
import kotlin.Throws

class TestChart : BaseDbActivity<BaseViewModel, AcTestChartBinding>() {
    override fun layoutId(): Int = R.layout.ac_test_chart


    data class TestCopy(var name: String, var id: Int) : Cloneable {
        @Throws(CloneNotSupportedException::class)
        @Override
        override fun clone(): Any {
            return super.clone() as TestCopy
        }

    }

    val testList = mutableListOf(
        TestCopy("test1", 1),
        TestCopy("test2", 2),
        TestCopy("test3", 3),
    )

    override fun initView(savedInstanceState: Bundle?) {

        val testCopyListNew = mutableListOf<TestCopy>()
//        val copyList = ListCopy.deepCopy(testList)mai
        for (i in testList.indices) {

            val testCopy = testList[i].copy()
            testCopyListNew.add(testList[i])

            testCopy.name = "修改 $i"

            testList[i] = testCopy

        }
        Log.e(
            "测试复制 ",
            "testCopyListNew：\n ${JSON.toJSON(testCopyListNew)} \n testList:\n ${JSON.toJSON(
                testList
            )}"
        )
    }

    override fun createObserver() {

    }

    override fun initData() {

    }
}